package com.walter.vo.page;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 分页响应数据
 *
 * @author wuchenxi
 * @date 2020-08-08 11:35:19
 */
@Data
@ApiModel
public class PageVO<T> implements Serializable {

    @ApiModelProperty(name = "list", value = "分页数据")
    private List<T> list;

    @ApiModelProperty(name = "pages", value = "总页数")
    private Long pages;

    @ApiModelProperty(name = "total", value = "总数据量")
    private Long total;

    @ApiModelProperty(name = "currentPage", value = "当前页")
    private Long currentPage;

    @ApiModelProperty(name = "pageSize", value = "每页数据量")
    private Long pageSize;

    public PageVO(Page<T> page) {
        this.list = page.getRecords();
        this.pages = page.getPages();
        this.total = page.getTotal();
        this.currentPage = page.getCurrent();
        this.pageSize = page.getSize();
    }
}
